# -*- coding: utf-8 -*-
"""
 ----------------------------------------
|File Name:     db_con
|Author:        WYT
|date:          2020/6/19
 ----------------------------------------
|  Change Activity:
|                   2020/6/19:
-----------------------------------------
"""
import pymysql
from DBUtils.PooledDB import PooledDB

from settings import online_config



dict_cursor = pymysql.cursors.DictCursor
hitech_pool = None
while True:
    try:
        hitech_pool = PooledDB(
            creator=pymysql,
            maxconnections=6,
            mincached=0,
            maxcached=5,
            maxshared=3,
            blocking=True,
            maxusage=None,
            setsession=[],
            ping=2,
            host=online_config.get("host"),
            port=online_config.get("port"),
            user=online_config.get("user"),
            password=online_config.get("password"),
            charset=online_config.get("charset"),
            database="hitech"
        )
    except Exception as err:
        print(err)
    else:
        break